package top.shiyiri.servlet2;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Aunean
 * @date 2022/1/27 14:12
 */
public class RequestAPIServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //getRequestURI()：获取请求的资源路径
        System.out.println("URI：" + req.getRequestURI());///day06_servlet_war_exploded/requestAPIServlet

        //getRequestURL()：获取请求的统一资源定位符
        System.out.println("URL：" + req.getRequestURL());

        //getRemoteHost()：获取客户端的IP地址
        System.out.println("IP地址：" + req.getRemoteHost());

        //getHeader()：获取请求头
        System.out.println("请求头：" + req.getHeader("User-Agent"));

        //getMethod()：获取请求的方式GET或POST
        System.out.println("请求方式：" + req.getMethod());
    }
}
